#include "network.hpp"
#include <SFML/Network.hpp>

sf::Uint8 Packet_Type(sf::Packet& Packet)
{
    sf::Uint8 type;
    Packet >> type;
    return type;
}

sf::Packet PK_CLT_PLMOVE(float x, float y, float velocity_x, float velocity_y, float angle)
{
    sf::Packet Packet;
    Packet << (sf::Uint8)PKTYPE_CLT_PLMOVE;
    Packet << x;
    Packet << y;
    Packet << velocity_x;
    Packet << velocity_y;
    Packet << angle;
    return Packet;
}

struct PKCONTENT_SRV_PLCONNECT PK_SRV_PLCONNECT(sf::Packet& Packet)
{
    struct PKCONTENT_SRV_PLCONNECT pkcontent;
    Packet >> pkcontent.pid;
    return pkcontent;
}

struct PKCONTENT_SRV_PLDISCONNECT PK_SRV_PLDISCONNECT(sf::Packet& Packet)
{
    struct PKCONTENT_SRV_PLDISCONNECT pkcontent;
    Packet >> pkcontent.pid;
    return pkcontent;
}

struct PKCONTENT_SRV_PLPOS PK_SRV_PLPOS(sf::Packet& Packet)
{
    struct PKCONTENT_SRV_PLPOS pkcontent;
    Packet >> pkcontent.pid;
    Packet >> pkcontent.x;
    Packet >> pkcontent.y;
    Packet >> pkcontent.vel_x;
    Packet >> pkcontent.vel_y;
    Packet >> pkcontent.rotation;
    return pkcontent;
}

struct PKCONTENT_CLT_PLMOVE PK_CLT_PLMOVE(sf::Packet& Packet)
{
    struct PKCONTENT_CLT_PLMOVE pkcontent;
    Packet >> pkcontent.x;
    Packet >> pkcontent.y;
    Packet >> pkcontent.vel_x;
    Packet >> pkcontent.vel_y;
    Packet >> pkcontent.rotation;
    return pkcontent;
}

sf::Packet PK_SRV_PLCONNECT(sf::Int32 pid)
{
    sf::Packet Packet;
    Packet << (sf::Uint8)PKTYPE_SRV_PLCONNECT;
    Packet << pid;
    return Packet;
}

sf::Packet PK_SRV_PLDISCONNECT(sf::Int32 pid)
{
    sf::Packet Packet;
    Packet << (sf::Uint8)PKTYPE_SRV_PLDISCONNECT;
    Packet << pid;
    return Packet;
}

sf::Packet PK_SRV_PLPOS(sf::Int32 pid, float x, float y, float velocity_x, float velocity_y, float rotation)
{
    sf::Packet Packet;
    Packet << (sf::Uint8)PKTYPE_SRV_PLPOS;
    Packet << pid;
    Packet << x;
    Packet << y;
    Packet << velocity_x;
    Packet << velocity_y;
    Packet << rotation;
    return Packet;
}
